<template>
  <div>
    <van-nav-bar title="商品列表" left-arrow @click-left="back"></van-nav-bar>
    <van-card
      v-for="(item, index) in List.list"
      :key="index"
      :price="item.price"
      desc="描述信息xxxx"
      :title="item.goodsname"
      :thumb="'http://localhost:3000' + item.img"
      @click="shopcar(item.id)"
    >
      <template #tags>
        <van-tag plain type="danger">标签</van-tag>
        <van-tag plain type="danger">标签</van-tag>
      </template>
      <template #footer>
        <van-button size="mini">商品详情</van-button>
      </template>
    </van-card>
  </div>
</template>

<script>
import { getcateGoods } from "../request";
export default {
  data() {
    return {
      size: 9,
      page: 1,
      List: [],
    };
  },
  created() {
    this.getData(this.$route.params.id);
  },
 
  methods: {
    // 要跳转的地址
    shopcar(id) {
      this.$router.push("/home/details/" + id);
    },
    async getData(id) {
      let res = await getcateGoods(id, this.size, this.page);
      this.List = res.list;
      console.log(this.List);
    },
     back(){
    this.$router.go(-1)
  },
  },
};
</script>

<style>
</style>